
//
//  ZYStudentLstCell.m
//  优学荟管理系统
//
//  Created by Ethan on 2017/9/19.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "ZYStudentLstCell.h"
#import "ZYStudentListModel.h"
@implementation ZYStudentLstCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        [self setUpSuperView];
    }
    
    
    return self;
    
}


- (void)assignByZYStudentListModel:(ZYStudentListModel *)model{
    
    self.accountNumberLabel.text = [NSString stringWithFormat:@"%@",model.username];
    self.nameLabel.text = [NSString stringWithFormat:@"%@",model.petname];
    
    
}


- (void)setUpSuperView{
    
    self.accountNumberLabel = [UILabel new];
    self.accountNumberLabel.font = [UIFont systemFontOfSize:12];
    self.accountNumberLabel.textColor = ColorRGB(102, 102, 102);
    self.accountNumberLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.accountNumberLabel];
    
    self.nameLabel = [UILabel new];
    self.nameLabel.font = [UIFont systemFontOfSize:12];
    self.nameLabel.textColor = ColorRGB(102, 102, 102);
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.nameLabel];
    

    self.studentButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.studentButton setTitle:@"学生详情" forState:(UIControlStateNormal)];
    [self.studentButton setTitleColor:ColorRGB(42, 197, 127) forState:(UIControlStateNormal)];
    self.studentButton.titleLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.studentButton];
    
    
    [self.accountNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        
        make.width.offset([UIScreen mainScreen].bounds.size.width/3);
    }];
    
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.accountNumberLabel);
        make.width.equalTo(self.accountNumberLabel);
        make.left.equalTo(self.accountNumberLabel.mas_right).offset(0);
    }];
    
    [self.studentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.accountNumberLabel);
        make.width.equalTo(self.accountNumberLabel);
        make.right.equalTo(self).offset(0);
    }];
    
    
    UILabel *grayLabel = [UILabel new];
    grayLabel.backgroundColor = ColorRGB(247, 244, 248);
    [self.contentView addSubview:grayLabel];
    [grayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(5);
        make.top.equalTo(self.studentButton.mas_bottom).offset(5);
        make.width.offset(SCREEN_WIDTH - 10);
        make.height.offset(1);
    }];
    
    [self.contentView  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(grayLabel).offset(0);
    }];
    
    
    
}



@end
